<template>
	<div>
		<el-form :model="state.form" ref="formRef" :rules="state.rules" style="width: 500px">
			<!-- <el-form-item label="测试" prop="test">
				<el-input v-model="state.form.test">
					<template #suffix>
						<div class="code_txt">获取验证码</div>
					</template>
				</el-input>
			</el-form-item> -->

			<el-form-item label="测试" prop="test">
				<el-input v-model="state.form.test" oninput="value =value?.replace(/\s/g, '')"> </el-input>
			</el-form-item>
		</el-form>

		<el-button @click="handleSub">submit</el-button>
	</div>
</template>

<script setup>
import { reactive, ref } from 'vue'
const formRef = ref()
const state = reactive({
	form: {},
	rules: {
		test: [
			{
				required: true,
				message: '请输入'
			}
		]
	}
})
// const inputChange = (value) => {
//     console.log("value",value);
//     state.form.test = value?.replace(/\s/g, '')
//     console.log("state.form.test",state.form.test);
// }
const handleSub = () => {
	formRef.value.validate(valid => {
		console.log(valid)
	})
}
</script>

<style scoped lang="scss">
.code_txt {
	color: #fa5123;
	padding-left: 5px;
	height: 20px;
	line-height: 20px;
	border-left: 1px solid #ccc;
}
</style>
